Skip to main content

All Questions

Tagged with
0votes
1answer
110views

uncomment the line upon search string while ignoring case in a file

Below is my cron file entries: #Ansible: test2 */15 * * * * ansible-playbook /web/playbooks/automation/detect401MORTEN/va_action.yml | tee -a /web/playbooks/automation/detect401MORTEN/cron.out # #...
Ashar's user avatar
0votes
2answers
1kviews

Replace specified strings in file with strings from other file with sed [duplicate]

I have two files like this. file1 line 1 line 2 ... (more lines) aaa PLACEHOLDER bbb ccc ... (more lines) ddd PLACEHOLDER eee fff ... (more lines) etc file2 NEWTEXT1 NEWTEXT2 ... (more lines) There ...
tom's user avatar
  • 77
0votes
2answers
493views

How to do find and replace strings on file after it is being modified

Trying to achieve following: 1) New file gets uploaded with the same file name but with new content 2) Event triggers that checks the file for specific strings and replaces them 3) The file can be ...
Lauris Kārkliņš's user avatar
2votes
1answer
2kviews

How to express beginning and end of line in sed

I want to use sed to replace every '} that comes at the end of the line to "}. I wrote: sed -i -e "s/'}$/\"}$/g" But this replaces it to: "}$. What is wrong? How can I use regex in my sed to express ...
user9371654's user avatar
2votes
3answers
585views

Conditionally replace lines of file1 with the corresponding lines of file2

For example, I have two files: file1: 1 4 X 5 X 7 file2: 2 3 5 X X 1 I want to replace X-lines of file1 with whatever is in file2 on the corresponding line: result: 1 4 5 5 X 7 I prefer the ...
Fibo Kowalsky's user avatar
2votes
2answers
626views

Using sed (or anything useful) to replace strings with relative content

Usually to replace strings across multiple files, one simply needs to use sed -i 's/string1/string2/g' * However, how could I use the sed command (or anything that works, really) to replace things ...
esote's user avatar
11votes
3answers
42kviews

Save file after using sed command

I am using following command to replace yyyymmdd to YYYYMMDDHH24MISS in my file: sed -e 's/\('yyyymmdd'\)/\('YYYYMMDDHH24MISS'\)/g' filename After I run the command in PuTTY, it displays the file ...
Hardik Kotecha's user avatar
3votes
5answers
1kviews

Replacing lines in files with file contents

I have several files which contain some PHP includes and I want to substitute them with the file contents. The file looks like foo <?php include("file1.php"); ?> bar baz <?php include("file2....
qbi's user avatar
  • 1,449

close